/**
 * 
 */
package com.zxc.redis.RAtomicLong;

import org.redisson.Redisson;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

/**
 * @author Administrator
 *
 */
public class RAtomicLongDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Config config = new Config();
		config
			//.setCodec(new FstCodec())
			.useSingleServer() //单例模式
			.setAddress("192.168.1.122:6379")//连接地址
			.setDatabase(1) // 数据库索引位置
			.setPassword("shijie99test") // 密码
			.setClientName("channelbatch") // 客户端名称
			;
		RedissonClient redisson = Redisson.create(config);
		
		RAtomicLong atomicLong = redisson.getAtomicLong("myAtomicLong");
		
		long l = atomicLong.incrementAndGet();
		System.out.println("incrementAndGet后的值："+l);
		
		l = atomicLong.incrementAndGet();
		System.out.println("incrementAndGet后的值："+l);
		
		l = atomicLong.addAndGet(3);
		System.out.println("addAndGet后的值："+l);
		
		l = atomicLong.getAndAdd(1);
		System.out.println("getAndAdd后的值："+l);
		
		atomicLong.set(3);
		l = atomicLong.get();
		System.out.println("set、get后的值："+l);
		
		redisson.shutdown();
	}

}
